package org.gruposp2p.openid

import grails.converters.deep.XML
import grails.converters.deep.JSON

//Si hay problemas con el renderizado:
//After println request.format on various Post requests, 
//I saw that format == 'form'......  not 'html'!
//I'm not sure if this is suppose to be intuitive for developers (!!) -- 
//the withForm {} documentation does not even mention it.... but at least 
//I know where to go from here.
//El tema se discute en:
//http://grails.1312388.n4.nabble.com/About-had-it-with-withFormat-td2135699.html
//https://www.ibm.com/developerworks/java/library/j-grails09168/
//
class RestController {
	
	def resourceTime = {
			
//			static allowedMethods =
//			    [startAction: 'POST', stopAction: 'DELETE',
//			     playAction: 'PUT', winAction: 'PUT',
//			     totalizerAction: 'GET']


			  switch(request.method){
			    case "POST":
			      //render "Create\n"
			      break
			    case "GET":
			      //render "Retrieve\n"
			      break
			    case "PUT":
			      //render "Update\n"
			      break
			    case "DELETE":
			      //render "Delete\n"
			      break
			  }   

		    withFormat {
		        json { render mydata as JSON } 
		        xml { render mydata as XML }
		        html {
		            render(view: 'display', model: mydata)
		        }
		        //Este para el caso de un post
		        //http://grails.1312388.n4.nabble.com/About-had-it-with-withFormat-td2135699.html
		        form {
		            render(view: 'display', model: mydata)
		        } 
		    }
			
	}
	
}
